<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			.bbb{width:100px;height: 100px;background-color: yellow;
				position: relative;}
			.ccc{width:50px;height: 50px;background-color: red;
				position:relative;left:10px;top:10px;}
		</style>
		
		<script src="../js/jquery-3.2.0.js" type="text/javascript"></script>
		
		<script type="text/javascript">
//offset	元素离窗口左上角距离	left,top
			$(function(){
				console.log("元素离窗口左边距离："+$('.aaa').offset().left
					+"离窗口上边距离："+ $('.aaa').offset().top + 'px'
				);


//position	元素相对于父元素的偏移位置   		10
				console.log('.ccc相对于.bbb向左偏移了：'+
					$('.ccc').position().left + 'px'
				)
				
//scrollTop、scrollLeft		滚动条相对于窗口的位置		可赋值
				$(window).scrollTop(500);
			})
		</script>
	</head>
	<body>
		<div class="aaa">0000000000000</div>
		<div class="bbb">
			<div class="ccc"></div>
		</div>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
		<p>1</p>
	</body>
</html>
